import * as faceapi from "face-api.js";

main()

async function main(){
    //模型权重文件加载
    await faceapi.nets.ssdMobilenetv1.loadFromUri('http://127.0.0.1:8888/weights')
    await faceapi.nets.faceLandmark68Net.loadFromUri('http://127.0.0.1:8888/weights')
    await faceapi.nets.faceRecognitionNet.loadFromUri('http://127.0.0.1:8888/weights')

    const input = document.getElementById('image')

    const detections = await faceapi.detectAllFaces(input)
    const faceImages = await faceapi.extractFaces(input, detections)

    console.log(faceImages);

    const facesContainer = document.getElementById('facesContainer')

    faceImages.forEach(canvas=>{
        facesContainer.appendChild(canvas)
    })

    closeLoading()    
}